﻿///找到最大素数
using System;
namespace MaxPrimeNumber
{
    internal class Program
    {
        static void Main(string[] args)
        {
             int PrimeNum = 1;
            Console.WriteLine("Input a num,please:");
            ///输入范围
            int n =int.Parse(Console.ReadLine());
            ///利用循环判断素数
            DateTime BeforeRuning = DateTime.Now;
            for (int i = 2; i <= n; i++)
            {
                for (int j = 2; j <=i; j++)
                {
                    if (i % j == 0)
                        ///每次找到当前最大素数
                        if (j == i)
                            PrimeNum = i;  
                        else break;
                }
            }
            Console.WriteLine("The maximun prime number is:");
            Console.WriteLine(PrimeNum);
            ///计算代码运行时间
            DateTime AfterRuning =DateTime.Now;
            TimeSpan RuningTime = AfterRuning.Subtract(BeforeRuning);
            Console.Write("Runing time:");
            Console.WriteLine(RuningTime);
        }
    }    
}   
                       
               
           